<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <img src="./images/desktop_1.jpg" alt="">
    <script>
        // 生成n-m任意数的函数
        function getNtoM(m = 0, n = 0) {
            return Math.floor(Math.random() * (m - n + 1)) + n
        }

        // 获取图片的元素
        const img = document.querySelector('img')
        // 生成图片的随机数
        const random = getNtoM(1, 10)
        // 替换图片的路径

        img.src = `./images/desktop_${random}.jpg`
    </script>
</body>

</html>